package com.alex.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;

/**
 * 使用Pipeline发送消息
 *
 * @author shufei
 */
public class PipelineTest {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("127.0.0.1", 6380);
        long setStart = System.currentTimeMillis();
        for (int i = 0; i < 100; i++) {
            Pipeline pipelined = jedis.pipelined();
            for (int j = i * 100; j < (j + 1) * 100; j++) {
                pipelined.hset("hashkey: " + j, "field" + j, "value: " + j);
            }

            pipelined.syncAndReturnAll();
        }

        System.out.println((System.currentTimeMillis() - setStart) / 1000_000);
    }
}
